/*
* @Author: liqs
* @Date:   2021/10/25 10:13
 */
package Utils

import (
	"bytes"
	"crypto/rand"
	"math/big"
)

// 生成指定长度的随机字符串
func CreateRandomString(len int) string {
	var container string
	var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	b := bytes.NewBufferString(str)
	length := b.Len()
	bigInt := big.NewInt(int64(length))
	for i := 0; i < len; i++ {
		randomInt, _ := rand.Int(rand.Reader, bigInt)
		container += string(str[randomInt.Int64()])
	}
	return container
}

func CheckErr(err error) {
	if err != nil {
		panic(err)
	}
}
